package ar.edu.utn.frba.tacs.warnes.servlets;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class InicioServlets extends HttpServlet {
	
	@Override
	public void init(ServletConfig config) throws ServletException {
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		String paramEntrada = req.getParameter("accion");
		
		if(paramEntrada != null && paramEntrada != ""){
			
			if(paramEntrada.equals("mostrar_partidos")){
				req.getRequestDispatcher("/partidos").forward(req, resp);
			}
			else if(paramEntrada.equals("crear_partido")){
				req.getRequestDispatcher("/nuevoPartido").forward(req, resp);
			}
			else if(paramEntrada.equals("modificar_jugador")){
				req.getRequestDispatcher("/modifJugador").forward(req, resp);
			}
			else if(paramEntrada.equals("crear_jugador")){
				req.getRequestDispatcher("/nuevoJugador").forward(req, resp);
			}
		}
		else {
			req.getRequestDispatcher("/jsp/index.jsp").forward(req, resp);
		}
	}

}
